package com.test.springboot_test.stringTest;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StringTest8 {

    public static void main(String[] args) {
        /**
         * 字符串的基本操作
         * 1.字符串的截取
         * 2.字符串的拼接
         * 3.字符串的索引，匹配从前往后
         * 4.字符串的索引，匹配从后往前
         * 5.字母从大到小，字符串切换
         * 6.字母从小到大，字符串切换
         * 7.逗号分割
         */
        //1.逗号分隔转数组
        String a = "1,2,3,4,5,6,7,8,9,10";
        String[] split = a.split(",");
        //将数组转化为流，放入新的集合里面去
        List<String> list = Arrays.asList(split);
        List<Integer> collect = list.stream().map(item -> Integer.parseInt(item)).collect(Collectors.toList());
        System.out.println(collect);

        //2.字符串的截取
        String str ="1+1=@2";
        System.out.println(str.substring(0, str.lastIndexOf("@")));
        System.out.println(str.substring(str.lastIndexOf("@") + 1));

        //3.字符串的拼接
        String str1[] = {"a","b","c"};
        StringBuilder builder = new StringBuilder();
        for(String a1 : str1){
            builder.append(a1);
        }
        System.out.println(builder.toString());

    }


}
